home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************
- *
- * PROGRAM NAME: PLAYVOCD.C
- *
- * COMPILER: Borland/Turbo C/C++
- *
- * DESCRIPTION: Plays a .VOC file from the disk using the CTVDSK.DRV
- * double buffering driver (accessed from SBSIM). To run
- * the program, type the following at the command line:
- *
- * PLAYVOCD FILENAME
- *
- * Where FILENAME is the drive/path/filename of the .VOC
- * file to play.
- *
- * NOTE: SBSIM driver must be loaded before running this program.
- *
- *********************************************************************/
- #define VOC_DSK_DRIVER 0x02
-
- #include <ctype.h>
- #include <conio.h>
- #include <fcntl.h>
- #include <io.h>
- #include <stdio.h>
- #include "drvrfunc.c"
- #include "drvrfunc.h"
-
-
- /********************************************************************/
- void main(int argc, char **argv)
- {
- char Command,
- UserQuit;
-
- int FileHandle;
- SIMERR RetValue;
-
- if (argc != 2) // argc = no. of parameters entered on command line
- {
- puts("Command line must contain EXACTLY ONE filename parameter!");
- return; // Terminate program
- }
-
-
- /*--- SEE IF SBSIM DRIVER HAS LOADED ------------*/
- SIMint = FindDvr("SBSIM", 0x0103); // Get SBSIM's interrupt no.
- if (SIMint == 0)
- {
- puts("SBSIM driver not loaded!");
- return; // Terminate program
- }
-
- /*--- SEE IF CTVDSK.DRV DRIVER HAS LOADED -------*/
- if (!(GetDrvrs() & VOC_DSK_DRIVER))
- {
- puts("CTVDSK.DRV not loaded!");
- return; // Terminate program
- }
-
-
- /*--- LOAD THE FILE SPECIFIED ON COMMAND LINE (stored in argv[1]) ----*/
- if ((FileHandle = _open(argv[1], O_BINARY | O_RDONLY)) == -1)
- {
- printf("FILE: %s not successfully opened!\n", argv[1]);
- return; // Terminate program
- }
-
-
- /*--- StartSnd() LOADS THE FILE AND INITIALIZES THE CTVDSK.DRV DRIVER. ---*/
- RetValue = StartSnd(DskVoice, (void far *) argv[1], NULL, NULL);
- if (RetValue != SIMerr_NoErr)
- {
- printf("ERROR CALLING SBSIM: %s\n", errorMsg[RetValue]);
- _close(FileHandle);
- return; // Terminate program
- }
-
- /*--- BEGIN PLAYING OF THE FILE -----------------------------------------*/
- RetValue = PlaySnd(DskVoice);
- if (RetValue != SIMerr_NoErr)
- {
- printf("ERROR CALLING SBSIM: %s\n", errorMsg[RetValue]);
- _close(FileHandle);
- return; // Terminate program
- }
-
- clrscr(); // Clear screen
- printf("\n\n\n\n\n SELECT ONE OF THE FOLLOWING OR WAIT UNTIL DONE:\n\n");
- printf(" (P)ause\n");
- printf(" (R)esume\n");
- printf(" (Q)uit\n");
-
- UserQuit = FALSE;
-
-
- /*--- PROCESS USER INTERACTION OR WAIT FOR SOUND TO STOP -----------*/
- do
- {
- if (kbhit()) // Was a key pressed?
- {
- Command = toupper(getch()); // Get char typed and convert to upper case
- if (Command == 'P')
- PauseSnd(DskVoice);
- else if (Command == 'R')
- ResumeSnd(DskVoice);
- else if (Command == 'Q')
- UserQuit = TRUE;
- }
- // Exit do-while loop if file is done playing or user typed 'Q'
- } while (GetSndStat(DskVoice) != 0 && UserQuit == FALSE);
-
-
- /*--- IF SOUND IS STILL PLAYING AND USER HIT 'Q', STOP THE SOUND ---*/
- if (GetSndStat(DskVoice) != 0 && UserQuit == TRUE)
- StopSnd(DskVoice);
-
- return;
- }
-